package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.utils.YMTDateUtil;

public class IPReferWapper {
	SqlManager manage;

	public IPReferWapper() {
		manage = new SqlManager("IPRefer");
	}

	public List<Map> IPRefer(String sLoginId, int iAction, String sLoginIp, String sClientType){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("sLoginId", sLoginId);
		params.put("iAction", iAction);
		params.put("sLoginIp", sLoginIp);
		params.put("sClientType", sClientType);
		params.put("addTime", YMTDateUtil.getBeforeOrNextSecond(-5));
		List<Map> loginHistory = manage.getSelectResults(
				"com.ymttest.database.mapping.AuthLoginHistoryMapper.selectLoginHistory", params);
		return loginHistory;
	}
	
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}

	
	public static void main(String[] args) {
		List<Map> userAuth = new AuthLoginHistoryWapper().selectLoginHistory("lgqq", 546590, "1.1.3.1", "mainsite");
		System.out.print(userAuth.size());
	}
}
